<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace App\Admin\Request;

use Mine\MineFormRequest;

/**
 * 车辆列表验证数据类
 */
class CarRequest extends MineFormRequest
{
    /**
     * 公共规则
     */
    public function commonRules(): array
    {
        return [];
    }
    
    /**
     * 新增数据验证规则
     * return array
     */
    public function saveRules(): array
    {
        return [
            //车辆分类ID 验证
            'car_category_ids' => 'required|array',
            'car_category_ids.*' => 'required|integer|gt:0',
            //轮播图 验证
            'banner' => 'required|array',
            'banner.*' => 'required|string|max:255|url',
            //封面图 验证
            'cover' => 'required|string|max:255|url',
            //名称 验证
            'name' => 'required|string|max:10',
            //单价(天) 验证
            'price' => 'required|integer|between:0,65535',
            //描述 验证
            'describe' => 'required|string|max:32',
            //基础配置 验证
            'base_config' => 'required|array',
            'base_config.*.key' => 'required|string',
            'base_config.*.value' => 'required|string',
            //突出配置 验证
            'high_light_config' => 'required|array',
            'high_light_config.*.key' => 'required|string',
            'high_light_config.*.value' => 'required|string',
        ];
    }

    /**
     * 更新数据验证规则
     * return array
     */
    public function updateRules(): array
    {
        return $this->saveRules();
    }

    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '',
            'car_category_ids' => '车辆分类ID',
            'car_category_ids.*' => '车辆分类ID',
            'banner' => '轮播图',
            'banner.*' => '轮播图',
            'cover' => '封面图',
            'name' => '名称',
            'price' => '单价(天)',
            'describe' => '描述',
            'base_config' => '基础配置',
            'base_config.*.key' => '基础配置名称',
            'base_config.*.value' => '基础配置描述',
            'high_light_config' => '突出配置',
            'high_light_config.*.key' => '突出配置名称',
            'high_light_config.*.value' => '突出配置描述',
        ];
    }
}